var E = window.wangEditor;
var newEditor = new E('#articleEditor');
// 或者 var editor = new E(document.getElementById('#editor') )
newEditor.customConfig.zIndex = 500; //配置z-index
newEditor.customConfig.uploadImgShowBase64 = true
$('pre code').each(function(i, block) {
	hljs.highlightBlock(block);
});
newEditor.create();
$('.w-e-text-container').height(600);

$(function() {

	$('.tagChooser li').each(function() {
		$(this).click(function() {
			var $this = $(this);
			if(!$this.hasClass('choosed')) {
				$this.addClass('choosed');
			} else {
				$this.removeClass('choosed');
			}
		});
	});

	$('.newTag').click(function() {
		var $this = $(this);
		var $tagBox = $(this).siblings('.tagBox');
		if($tagBox.width() == 0) {
			$tagBox.width(140);
			$this.removeClass('fa-plus').addClass('fa-minus');
		} else {
			$tagBox.width(0);
			$this.removeClass('fa-minus').addClass('fa-plus');
		}
	});

	$('.tagBox .fa-check').click(function() {
		var $this = $(this);
		$this.parent(".tagBox").width(0);
		$this.parent(".tagBox").siblings('.newTag').removeClass('fa-minus').addClass('fa-plus');
		var $newTagInput = $this.siblings('.newTagInput');
		var $tagChooser = $this.parents('.tagHeader').siblings('.tagChooser');
		if($newTagInput.val().replace(/(^\s*)|(\s*$)/g, "") != '') {
			$tagChooser.prepend('<li class="choosed">' + $newTagInput.val() + '</li>');
			$newTagInput.val('');
		}
	});

})